<tuple-name>=(value1,value2,...,valueN)
tp1 = ("apple","banana","cherry") tp2 = ("Amit Jain",23,"male") tp3 = (4117,"Amit Jain",['C','C++','Java','Python']) print(tp1) print(tp2) print(tp3)
('apple', 'banana', 'cherry') ('Amit Jain', 23, 'male') (4117, 'Amit Jain', ['C', 'C++', 'Java', 'Python'])
<tuple_name>[index]
<tuple_name>[startindex:stopindex:step]
tp=("apple","banana","cherry","mango","grapes") print( tp[ 2 ] ) print( tp[ 0 ] ) print( tp[ -1 ] ) print( tp[ 1 : 3 ] ) print(tp[ : 2 ]) print(tp[ 2: ]) print( tp[ : :2 ] ) print( tp[ : :-1] )
cherry apple grapes ('banana', 'cherry') ('apple', 'banana') ('cherry', 'mango', 'grapes') ('apple', 'cherry', 'grapes') ('grapes', 'mango', 'cherry', 'banana', 'apple')